<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<%@ include file="/taglibs.jsp"%>

<script src="/js/grid.locale-en.js" type="text/javascript"></script>
<script src="/js/jquery.jqGrid.min.js" type="text/javascript" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" media="screen" href="/css/ui.jqgrid.css" />
<link href="/css/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" media="screen" />


<c-rt:if test="${!empty couponItem.memberId && empty couponItem.orderId}">
<yaodian100:checkPermission permissions="OTHER_COUPON,OTHER_CANCELCOUPON">
<script language="javascript">
$().ready( function() {
	$("#cancelCoupon").click(function(){
		if(confirm("确定要取消?")){
			$.post("${midContextPath}/coupon/jsonCancelCoupon.do",{couponItemCode:'${couponItemCode}'},
				cancelResult,"json");
		}
		return null;
	});
});
function cancelResult(result){
	if('OK'==result){
		alert("取消成功");
	}else if('is_used'==result){
		alert("优惠券已被使用");
	}else if('not_reg'==result){
		alert("优惠券未被注册");
	}else{
		alert("优惠码（Coupon Item Code）查无资料");
	}
	window.location.href='${midContextPath}/coupon/queryCouponByCouponItemCode.do?couponItemCode=${couponItem.code}';
}


</script>
</yaodian100:checkPermission>
</c-rt:if>

<div style="color:red">
<s:actionerror/>
<s:actionmessage/>
<s:fielderror />
</div>
<h1>Coupon Item 检视</h1>
<s:form action="save.do" method="post" id="formObj">
<h2>Coupon Item</h2>
<br/>
<table class="tb-data" id="mainTable" >
	<tbody>
        <tr>
          <th colspan="2">
                                优惠码资料
          </th>
        </tr>
		<tr>
			<th>
				优惠码
			</th>
			<td>
				
				<a href="javascript:doAR('<c-rt:url value="/json/couponLogs.do?couponCode=${couponItem.code}"/>', 'dialog');openDialog('coupon消费纪录',null,700,300)">${couponItem.code}</a>
				(
                <s:if test="%{couponItem.memberId == null && couponItem.orderId == null}">
					未啟用
                </s:if>
                <s:elseif test="%{couponItem.memberId != null && couponItem.orderId == null}">
                	未使用
                </s:elseif>
                <s:elseif test="%{couponItem.memberId != null && couponItem.orderId != null}">
					已使用
                </s:elseif>
				)
			</td>
		</tr>
		<tr>
			<th>
				会员代码
			</th>
			<td>
				<s:url id="viewMemberUrl" value="/member/view.do">
					<s:param name="memberId" value="%{couponItem.memberId}"></s:param>
				</s:url>
				<s:a href="%{viewMemberUrl}">
					${couponItem.memberId}
				</s:a>
			</td>
		</tr>
		<tr>
			<th>
				订单编号
			</th>
			<td>
				<s:url id="viewOrderUrl" value="/order/view.do">
					<s:param name="orderId" value="%{couponItem.orderId}"></s:param>
				</s:url>
				<s:a href="%{viewOrderUrl}" target="_blank">
					${couponItem.orderId}
				</s:a>
			</td>
		</tr>
		<tr>
			<th>
				充值日期
			</th>
			<td>
				<fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${couponItem.regDate}" />
			</td>
		</tr>
		<tr>
			<th>
				使用日期
			</th>
			<td>
				<fmt:formatDate pattern="yyyy-MM-dd HH:mm" value="${couponItem.useDate}" />
			</td>
		</tr>
		<tr>
			<th colspan="2" >礼券基本资料</th>
		</tr>
        <tr>
            <th>名称</th>
            <td>
              ${coupon.name}
            </td>
        </tr>
		<tr>
			<th>叙述</th>
			<td>
				${coupon.description}
			</td>
		</tr>
		<tr>
			<th>适用范围</th>
			<td>
				${applyRangTypeMenu.options[coupon.applyRangeType.code].name}
			</td>
		</tr>
		<tr>
			<th>范围设定
			</th>
			<td>
				${applyRangeTypeExtensionDisplay}
			</td>
		</tr>
		<tr>
		<th>激活日期</th>
			<td><fmt-rt:formatDate value="${couponItem.regDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
		</tr>
		<tr>
			<th>适用期间</th>
			<td>
				<fmt-rt:formatDate value="${couponItem.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>～<fmt-rt:formatDate value="${couponItem.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
			</td>
		</tr>
		<tr>
			<th>礼券面额</th>
			<td>
				¥&nbsp;${coupon.faceValue}
			</td>
		</tr>
		<tr>
			<th>最低商品价格</th>
			<td>
				¥&nbsp;${coupon.minimumProductPrice}
			</td>
		</tr>
        <s:if test="%{coupon.status == @com.yaodian100.ec.coupon.entity.Coupon$Status@INACTIVE}">
    		<tr>
    			<th>状态</th>
    			<td>
    				<strong>
	    				${statusMenu.options[coupon.status.code].name}
    				</strong>
    			</td>
    		</tr>
        </s:if>
		<tr>
			<th>数量</th>
			<td>
				${coupon.amount}
			</td>
		</tr>
		<tr>
			<th>单一帐号限用一次</th>
			<td>
				<s:if test="%{coupon.isOnce}">
					是
				</s:if>
				<s:else>
					否
				</s:else>
				<s:hidden name="coupon.isOnce"/>
			</td>
		</tr>
	</tbody>
</table>

<div class="f-link">
	<a href="toQueryCouponByCouponItemCode.do">回查询页</a>
	<c-rt:if test="${!empty couponItem.memberId && empty couponItem.orderId}">
		<yaodian100:checkPermission permissions="OTHER_COUPON"><a href="${midContextPath}/coupon/editCouponByCouponItemCode.do?couponItemCode=${couponItem.code}&from=fci">編輯 </a></yaodian100:checkPermission>
		<yaodian100:checkPermission permissions="OTHER_COUPON,OTHER_CANCELCOUPON"><a href="javascript:;" id="cancelCoupon">取消礼卷</a></yaodian100:checkPermission>
	</c-rt:if>
</div>
</s:form>